<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">

            <h:form id="cidadaoForm" enctype="multipart/form-data">
                <br/>
                <h3 class="title">Tramite Requerimento</h3>
                <p:growl id="messages" showDetail="false" autoUpdate="true"  />
                <p:panel id="tipoRequerimentoPanel" style="background: none; border: none;" 
                         styleClass="container_24 clearfix both ">
                    <h4 class="title">Resumo</h4>
                    <p:outputLabel value="Requerimento " styleClass="grid_3" /> 
                    <p:outputLabel value="#{managerEditarRequerimento.editTramite.tipoRequerimento.name}" /> 
                    <div class="clear"/>

                    <p:outputLabel value="N˚ Processo " styleClass="grid_3" /> 
                    <p:outputLabel value="#{managerEditarRequerimento.editTramite.processo}" /> 
                    <div class="clear"/>

                    <fieldset>
                        <legend>Interessado</legend>
                        <p:outputLabel value="Interessado " styleClass="grid_3" />
                        <p:outputLabel value="#{managerEditarRequerimento.editTramite.nomeInteressado}" />
                        <div class="clear"/>

                        <p:outputLabel value="CPF/CNPJ " styleClass="grid_3" />
                        <p:outputLabel value="#{managerEditarRequerimento.editTramite.tipoDocumentoInteressado.tipo eq 'CPF' ? 
                                                managerEditarRequerimento.editTramite.cpfInteressado : managerEditarRequerimento.editTramite.cnpjInteressado}" />
                    </fieldset>
                    <fieldset>
                        <legend>Proprietário</legend>
                        <p:outputLabel value="Proprietário " styleClass="grid_3" /> 
                        <p:outputLabel value="#{managerEditarRequerimento.editTramite.nomeProprietario}" />
                        <div class="clear"/>
                        <p:outputLabel value="CPF/CNPJ " styleClass="grid_3" />
                        <p:outputLabel value="#{managerEditarRequerimento.editTramite.tipoDocumentoProprietario.tipo eq 'CPF' ? 
                                                managerEditarRequerimento.editTramite.cpfProprietario : managerEditarRequerimento.editTramite.cnpjProprietario}" />
                    </fieldset>
                    <fieldset>
                        <legend>Imóvel</legend>
                        <p:outputLabel value="Cep " styleClass="grid_3" /> 
                        <p:outputLabel value="#{managerEditarRequerimento.editTramite.cepImovel}" />
                        <div class="clear"/>

                        <p:outputLabel value="Endereço " styleClass="grid_3" />
                        <p:outputLabel value="#{managerEditarRequerimento.editTramite.enderecoImovel}" />
                        <div class="clear"/>

                        <p:outputLabel value="Bairro " styleClass="grid_3" />
                        <p:outputLabel value="#{managerEditarRequerimento.editTramite.bairroImovel}" />
                        <div class="clear"/>

                        <p:outputLabel value="Numero " styleClass="grid_3" />
                        <p:outputLabel value="#{managerEditarRequerimento.editTramite.numImovel}" />
                    </fieldset>

                </p:panel>
                <p:panel id="documentosPanel" style="background: none; border: none;" 
                         styleClass="container_24 clearfix both ">
                    <h4 class="title">Dados Gerais</h4>

                    <p:outputLabel value="Status : " styleClass="grid_3" for="editStatus" />

                    <div class="grid_8">
                        <p:selectOneMenu id="editStatus" value="#{managerEditarRequerimento.editTramite.status}">
                            <f:selectItem  itemLabel="" itemValue=""/>
                            <f:selectItems value="#{managerEditarRequerimento.tipoStatus()}" /> 
                            <p:ajax event="change" update="@form"/>
                        </p:selectOneMenu>
                    </div>

                    <p:outputLabel value="N˚ Processo: " styleClass="grid_3" for="processoInputText" 
                                   rendered="#{managerEditarRequerimento.editTramite.status eq 'PROTOCOLO'}" />
                    <p:inputText id="processoInputText" styleClass="grid_8" 
                                 value="#{managerEditarRequerimento.editTramite.processo}"
                                 rendered="#{managerEditarRequerimento.editTramite.status eq 'PROTOCOLO'}" />
                </p:panel>
                <p:panel id="finalizarRequerimentoPanel"
                         rendered="#{managerEditarRequerimento.editTramite.status eq 'FINALIZAR'}"
                         style="background: none; border: none;" 
                         styleClass="container_24 clearfix both "> 
                    <h4 class="title">Caixa Requerimento</h4>

                    <p:outputLabel value="Data Pag: " styleClass="grid_3" for="dataInputText"/>

                    <p:calendar id="dataInputText" styleClass="grid_8" 
                                value="#{managerEditarRequerimento.editTramite.caixaRequerimento.dataCriacao}"
                                showOn="button" locale="pt" yearRange="1900:2020" required="true"  
                                navigator="true" pattern="dd/MM/yyyy" />
                </p:panel>
                <p:panel id="entradaRequerimentoPanel"
                         rendered="#{managerEditarRequerimento.editTramite.status eq 'ENTRADA'}"
                         styleClass="container_24 clearfix both withoutBorder"> 

                    <h4 class="title">Caixa Requerimento</h4>
                    <p:outputLabel value="Valor " styleClass="grid_3" for="arInputText" />
                    <p:inputText id="arInputText" styleClass="grid_7" 
                                 value="#{managerEditarRequerimento.editTramite.caixaRequerimento.valor}"
                                 onkeypress="jQuery(this).autoNumeric({aSep: '.', aDec: ','} );">
                        <f:convertNumber pattern="#,###,##0.00" locale="pt,BR"/>
                    </p:inputText>
                    <!--                    <p:inputText id="valorInputText" styleClass="grid_8" 
                                                     value="{managerEditarRequerimento.editTramite.caixaRequerimento.valor}"
                                                       
                                                     />-->

                </p:panel>

                <div class="buttonAction"> 
                    <p:commandButton value="Salvar" icon="ui-icon-disk" update="@form"
                                     actionListener="#{managerEditarRequerimento.atualizarTramite()}"
                                     styleClass="ui-priority-primary" />

                    <p:button href="pesquisarrequerimento.xhtml" value="Cancelar"  icon="ui-icon-trash" />

                </div >
                <p:dialog id="modalDialog" header="Boleto" widgetVar="dlg" modal="true"
                          height="100" width="400" closable="true" resizable="false" >
                    <h:outputText value="Deseja imprimir o boleto?"/>
                    <div class="buttonAction" >
                        <p:commandButton id="gerarBoletoDialogCommandButton" ajax="false" 
                                         styleClass="printButton"
                                         value="Sim" actionListener="#{managerEditarRequerimento.imprimir(managerEditarRequerimento.editTramite)}"
                                         update="@form" style="width: 153px;" onclick="this.form.target='_blank';dlg.hide();"
                                         icon="ui-icon-check"  /> 

                        <p:commandButton value="Não" icon="ui-icon-close" 
                                         actionListener="#{managerEditarRequerimento.redirectVisualizarRequerimento()}" />
                    </div>
                    <script>
                        $('.printButton').mouseup(function(){     
                            window.open("visualizarrequerimento.xhtml?vReq=#{managerEditarRequerimento.editTramite.id}", "_SELF");
                        });
                    </script>
                </p:dialog>

            </h:form>
        </ui:define>
    </ui:composition>

</html>
